
const message = (page, message, type) => {
  if (page) {
    type = type == null ? 'warning' : type
    page.$message({
      message: message,
      type: type })
  }
}

const validatePrice = (value, callback) => {
  // console.log('--')
  var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
  if (reg.test(value)) {
    return true
  }
  return false
}

const checkPhone = (phone) => {
  console.log(phone)
  console.log((/^1[23456789]\d{9}$/.test(phone)))
  if (/^1[23456789]\d{9}$/.test(phone)) {
    return true
  } else if (/^0\d{2,3}-?\d{7,8}$/.test(phone)) {
    return true
  }
  return false
}

export {
  message,
  validatePrice,
  checkPhone
}

